//
//  AISBLEDeviceManager.h
//  ParkingCloud
//
//  Created by Ares on 16/5/9.
//  Copyright © 2016年 NJSubier. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

@protocol AISBLEDeviceManagerDelegate;
@protocol AISBLEDeviceFactory;
@class AISBLEDevice;

/*! BLE设备管理单例类
 * 负责设备的搜索、记录、连接等。
 */
@interface AISBLEDeviceManager : NSObject

+ (AISBLEDeviceManager *)sharedInstance;

@property (nonatomic, weak) id<AISBLEDeviceManagerDelegate> delegate;
@property (nonatomic, weak) id<AISBLEDeviceFactory> deviceFactory;
@property (nonatomic, strong) NSMutableArray<AISBLEDevice *> *foundDevices;
@property (nonatomic, strong) NSMutableArray<AISBLEDevice *> *connectedDevices;

/*! 根据设备的ServiceUUID搜索设备 */
- (void)scanDevicesWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs;
- (void)stopScanning;

/*! 连接某设备 */
- (void)connectDevice:(nonnull AISBLEDevice *)device;
- (void)disconnectDevice:(nonnull AISBLEDevice *)device;

@end

/*! BLE设备管理代理回调 */
@protocol AISBLEDeviceManagerDelegate <NSObject>

@optional
- (void)bleDeviceManagerDidRefresh;
- (void)bleDeviceManagerDidStatePoweredOff;
- (void)bleDeviceDidStatusChanged:(nonnull AISBLEDevice *)device;

@end

/*! 设备工厂用于创建实际应用场景所需设备 */
@protocol AISBLEDeviceFactory <NSObject>

@optional
- (nonnull AISBLEDevice *)createDevice;

@end
